pub trait BitSet
{
	fn get_bit(&self, idx: usize) -> bool;
	fn set_bit(&mut self, idx: usize, value: bool);
}


// Strange method to create l bitset from u8
impl BitSet for u8
{
	fn get_bit(&self, idx: usize) -> bool
	{
		match self & (1 << idx)
		{
			0 => false,
			_ => true,
		}
	}

	fn set_bit(&mut self, idx: usize, value: bool)
	{
		*self = *self | (u8::from(value) << idx);
	}
	
}

#[cfg(test)]
mod tests
{
	use crate::BitSet;

	#[test]
	fn u8_bitset_get()
	{
		let bit_set: u8 = 0b1000_0100;

		assert_eq!(bit_set.get_bit(0), false);
		assert_eq!(bit_set.get_bit(2), true);
		assert_eq!(bit_set.get_bit(7), true);
	}

	#[test]
	fn u8_bitset_set()
	{
		let mut bit_set: u8 = 0b1000_0100;

		assert_eq!(bit_set.get_bit(4), false);
		bit_set.set_bit(4, true);
		assert_eq!(bit_set.get_bit(4), true);
	}
}
